<script setup lang="ts">
import { get_BiyeWork } from '@/request';
import * as echarts from 'echarts';
import { onMounted } from 'vue';

var option1 = {
  tooltip:{show:true},
 
  series: [
    {
      type: 'pie',
      radius: [30, 100],
      center: ['50%', '50%'],
      roseType: 'radius',
      itemStyle: {
        borderRadius: 0
      },
      data: [
        { value: 40, name: 'rose 1' },
        { value: 38, name: 'rose 2' },
        { value: 32, name: 'rose 3' },
        { value: 30, name: 'rose 4' },
      ]
    }
  ]
};
let status=[
    {
        status:'1',
        text:'待毕业'
    },
    {
        status:'2',
        text:'已毕业'
    },
    {
        status:'3',
        text:'已就业'
    },
    {
        status:'5',
        text:'返校重听'
    }
]
onMounted(() => {
    var chartDom = document.getElementById('BiyeWork');
    var myChart = echarts.init(chartDom);
    get_BiyeWork({
         gradYear: 2023
    }).then(resp => {
        console.log('毕业生工作状态',resp)
        option1.series[0].data=resp.data.data.result.map(item=>{
            return {
                value:item.total,
                name:status.find(v=>v.status===item.status).text
            }
        })
        myChart.setOption(option1)
         window.addEventListener('resize', function () {
            myChart.resize();
        });
    })

})

</script>

<template>
    <div id="BiyeWork">

    </div>
</template>

<style scoped lang="scss">
#BiyeWork {
    width: 100%;
    height: 34vh;
    // border: #fcc solid 1px;
}
</style>
